package com.masterlu.leetcode.daily.greedy.simple;

/**
 * @date created in 2021/5/27 17:24
 */
public class S122MaxProfit {

    public int maxProfit(int[] prices) {

        if (null == prices || prices.length == 0){
            return 0;
        }
        int maxProfit = 0;
        int current = prices[0];

        for (int i = 1; i < prices.length; i++) {
            if (prices[i] >prices[i-1]){
                maxProfit += (prices[i]-prices[i-1]);
            }
        }
        return maxProfit;
    }


    public boolean isPowerOfFour(int n) {
        while(n > 0){
            n /= 4;
            if(n == 1){
                return true;
            }
        }

        return false;
    }

}
